<?php
    require_once("condb.php");
    require_once("functions.php");
    
    $output = array();
    $info = isset($_GET["info"]) ? $_GET["info"] : "";
    if(!empty($info)){
        $info = urldecode(base64_decode($info));
        parse_str($info, $request);    
        
        $token = isset($request["token"]) ? cleanQuery($request["token"]) : "";
        if($token=="TAoViEC@)!#2012"){
            $data = array();
            
            $data["type"] = isset($request["type"]) ? cleanQuery($request["type"]) : "";
            $data["refCode"] = isset($request["refCode"]) ? cleanQuery($request["refCode"]) : "";           
            $data["ext"] = isset($request["ext"]) ? cleanQuery($request["ext"]) : "";           
            
            $user = getUser($data["refCode"]);
            if(!empty($user) && !empty($data["ext"]) && !empty($data["type"])){
                if($data["type"]==1){
                    $filename = "MyGame";
                } else if($data["type"]==2){
                    $filename = "mSexy";    
                } else if($data["type"]==3){
                    $filename = "mShow";    
                }
                
                $status["status"] = 1;
                $status["msg"] = baseUrl() . "upload/user/" . $user["username"] . "/" . $filename . "." . $data["ext"];                
            } else {
                $output["status"] = 0;
                $output["msg"] = "Không có phiên bản mới";    
            }
        } else {
            $output["status"] = 3;
            $output["msg"] = "Invalid Request";    
        }
    } else {
        $output["status"] = 2;
        $output["msg"] = "Invalid Request";
    }

    echo json_encode($output);  
?>
